package com.zcp.controller;

import com.zcp.entity.Class_Com;
import com.zcp.entity.Tag;
import com.zcp.entity.class_z;
import com.zcp.service.Class_ComService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;


@Controller
@RequestMapping("committee")
public class Class_ComController {

    @Autowired
    private Class_ComService class_comService;

    @RequestMapping("save")
    public String save(Class_Com Class_Com){
        class_comService.save(Class_Com);
        return "redirect:/committee/findAll";
    }

    @RequestMapping("findAll")
    public String findAll(Model model){
        List<Class_Com> class_coms = class_comService.finaAll();
        model.addAttribute("class_coms",class_coms);
        return "back/class_committee/index";
    }

    @GetMapping("change/{id}")
    public String change(@PathVariable("id") Integer id, Model model){
        Class_Com class_coms = class_comService.change(id);
        model.addAttribute("class_coms",class_coms);
        return "back/class_committee/change";
    }

    @RequestMapping("changed")
    public String changed(Class_Com Class_Com){
        class_comService.changed(Class_Com);
        return "redirect:/committee/findAll";
    }
    @GetMapping("delete/{id}")
    public String delete(@PathVariable("id") Integer id){
        class_comService.delete(id);
        return "redirect:/committee/findAll";
    }
}
